﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClassForWinForm
{
    public partial class Form7 : Form
    {
        public Form7()
        {
            InitializeComponent();
        }

        private void Form7_Load(object sender, EventArgs e)
        {
            for (int i = 1; i <= 20; i++)
            {
                checkedListBox1.Items.Add("选项" + i.ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string data = "";

            for(int i=0;i<checkedListBox1.CheckedItems.Count;i++)
            {
                data += checkedListBox1.CheckedItems[i].ToString() + "\r\n";
            }

            if (data != "")
            {
                MessageBox.Show("您选中的选项有：" + data, "提示");
            }
            else
            {
                MessageBox.Show("您没有选中任何选项！", "提示");
            }
        }
    }
}
